<template>
	<MyHead></MyHead>
	<div>
		<swiper :indicator-dots="true"
		  :autoplay="true" :interval="3000" :duration="500">
		  <block v-for="item,index in data" :key="index">
		    <swiper-item>
		     <image :src="item.imgs[0].imgSrc.replace('public',baseURL)" class="imgs"></image>
		    </swiper-item>
		  </block>
		</swiper>
		<van-tabs :active="active" @change="tbs">
		  <van-tab title="最热面试" :name='1'>	
			  <adminList :list="list" :isHot="true" :isTime="false"></adminList>
		  </van-tab> 
		  <van-tab title="最新面试" :name='2'>
			  <adminList  :list="list" :isTime="true" :isHot="false"></adminList>
		  </van-tab>
		</van-tabs>
	</div>

</template>

<script setup lang="ts">
import {baseURL} from '@/ulit/baseURL'
import {onBeforeMount,ref} from 'vue'
import {getBanners, getmsLIst} from '@/api/api'
import adminList from '@/component/adminLIst.vue'
import {onReachBottom} from '@dcloudio/uni-app'
// 定义轮播图数据
const data = ref<addmsType[]>([])
// 定义列表数据
const list = ref<addmsType[]>([])
const active = ref(1)
const total = ref(0)
const Hotpage = ref(1)
const TimePage = ref(1)
const type = ref(1)
onBeforeMount(async()=>{
  let res = await getBanners();
  data.value = res.result
  let res2 = await getmsLIst({type:type.value,page:1});
  total.value = res2.total
  list.value = res2.result

})

const tbs = async(obj)=>{
	type.value = obj.detail.name;
	Hotpage.value =1;
	TimePage.value =1;
	let res =await getmsLIst({type:type.value,page:1})
	list.value = res.result
}

// 下拉触底事件
onReachBottom(async()=>{
	//热度
	if(type.value == 1){
		Hotpage.value++
		let res = await getmsLIst({page:Hotpage.value,type:type.value})
			if(res.result.length<10){
				wx.showToast({title:"到底了"})
			}
		let arr = list.value.concat(res.result)
		list.value = arr
	//时间
	}else{
		TimePage.value++
		let res = await getmsLIst({page:TimePage.value,type:type.value})
			if(res.result.length<10){
				wx.showToast({title:"到底了"})
			}
		let arr = list.value.concat(res.result)
		list.value = arr
	}

})


</script>

<style scoped lang="scss">
	
.imgs{
	width: 100%;
	height: 100%;
}
</style>